home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 June (DVD) / DPPRO0605DVD.iso / Install / program files / Borland / BDS / 3.0 / Demos / Delphi.Net / CLR / Remoting / uTCPServInst.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2004-10-22  |  2.3 KB  |  79 lines

  1. unit uTCPServInst;
  2. //------------------------------------------------------------------------------
  3. //  Last updated:   11/06/03
  4. //  Author:         Dennis Passmore
  5. //  Company:        Ultimate Software, Inc.
  6. //  Contact info:   dennis_passmore@ultimatesoftware.com
  7. //
  8. //  Compatibility:  Delphi for .NET TCP service demo
  9. //
  10. //  Description:    ServiceInstaller for TmpService application
  11. //
  12. //------------------------------------------------------------------------------
  13. interface
  14.  
  15. uses
  16.   System.ServiceProcess,
  17.   System.Configuration.Install,
  18.   System.ComponentModel, // for RunInstaller
  19.   System.Collections,    // for IDictionary
  20.   Microsoft.Win32;       // for RegistryKey
  21.  
  22. const
  23.   cNTServiceDesc = 'Delphi for .NET TCP Service Demo';
  24.   cNTServiceDisp = 'Delphi TCP Service';
  25.   cNTServiceProg = 'D4DN_NT_TCPService';
  26.  
  27. type
  28.   [RunInstaller(True)]
  29.   TNTServiceInstaller = class(System.Configuration.Install.Installer)
  30.   private
  31.     fDepends: array of string;
  32.     fProcessInstaller: System.ServiceProcess.ServiceProcessInstaller;
  33.     fInstaller: System.ServiceProcess.ServiceInstaller;
  34.   strict protected
  35.     procedure OnAfterInstall(savedState: IDictionary); override;
  36.   public
  37.     constructor Create;
  38.   end;
  39.  
  40. var
  41.   NTServiceInstaller: TNTServiceInstaller = nil;
  42.  
  43. implementation
  44.  
  45. constructor TNTServiceInstaller.Create;
  46. begin
  47.   inherited Create;
  48.  
  49.   SetLength(fDepends, 1);
  50.   fDepends[0] := 'Event Log';
  51.  
  52.   fProcessInstaller := System.ServiceProcess.ServiceProcessInstaller.Create;
  53.   fProcessInstaller.Account := System.ServiceProcess.ServiceAccount.LocalSystem;
  54.  
  55.   fInstaller := System.ServiceProcess.ServiceInstaller.Create;
  56.   fInstaller.ServiceName := cNTServiceProg;
  57.   fInstaller.DisplayName := cNTServiceDisp;
  58.   fInstaller.StartType := System.ServiceProcess.ServiceStartMode.Manual;
  59.   fInstaller.ServicesDependedOn := fDepends;
  60.  
  61.   Installers.Add(fInstaller);
  62.   Installers.Add(fProcessInstaller);
  63. end;
  64.  
  65. procedure TNTServiceInstaller.OnAfterInstall(savedState: IDictionary);
  66. var
  67.   ServiceKey: RegistryKey;
  68. begin
  69.   ServiceKey := Microsoft.Win32.Registry.LocalMachine.OpenSubKey(
  70.     'SYSTEM\CurrentControlSet\Services\' + cNTServiceProg, True);
  71.   if (ServiceKey <> nil) then
  72.   begin
  73.     ServiceKey.SetValue('Description', cNTServiceDesc );
  74.     ServiceKey.Close;
  75.   end;
  76. end;
  77.  
  78. end.
  79.